﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using CUREBusinessLogicLayer;

/*************************************************************************************

     * 作   者： 张 颖
  
*************************************************************************************/
namespace CURE.SystemManagement
{
    public partial class AddModel : System.Web.UI.Page
    {
        #region 变量
        string id;

        public string Id
        {
            get { return id; }
            set { id = value; }
        }
        string action;
        public string Action
        {
            get { return action; }
            set { action = value; }
        }
        string url;

        public string Url
        {
            get { return url; }
            set { url = value; }
        }
        string modelName;

        public string ModelName
        {
            get { return modelName; }
            set { modelName = value; }
        }
        string actionSort;

        public string ActionSort
        {
            get { return actionSort; }
            set { actionSort = value; }
        }

        string fatherName;

        public string FatherName
        {
            get { return fatherName; }
            set { fatherName = value; }
        }
        #endregion
        ModulBll modelBll = new ModulBll();
        protected void Page_Load(object sender, EventArgs e)
        {
            BindfatherName();
            action = Request.QueryString["action"];
            if (action == "add")//新增
            {
                id = Request.QueryString["id"];
               modelName = "";
                url = "";
            }
            else if (action == "edit")//编辑
            {
                id = Request.QueryString["action_id"];
                DataTable dt = modelBll.GetModelById(id);
                if (dt != null && dt.Rows.Count > 0)
                {
                    modelName = dt.Rows[0]["action_name"].ToString().Replace(" ", "");
                    fatherName = dt.Rows[0]["action_columnid"].ToString().Replace(" ", "");
                    url = dt.Rows[0]["action"].ToString().Replace(" ", "");
                    actionSort = dt.Rows[0]["action_sort"].ToString();
                }
            }
        }
        /// <summary>
        /// 绑定上级模块
        /// </summary>
        protected void BindfatherName()
        {
            DataTable dt = modelBll.GetFatherModel();
            if (dt != null && dt.Rows.Count > 0)
            {
                reptModel.DataSource = dt;
                reptModel.DataBind();
            }
        }
    }
}
